package com.loopstack.gprint.utils;

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

import android.os.Handler;
import android.os.Looper;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class UIThreadManager {
    private static ExecutorService threadPool;
    private static Handler handler;
    private static final int POOL_SIZE = 5;

    public UIThreadManager() {
    }

    public static void onUIThread(Runnable runnable) {
        if (Thread.currentThread().getId() != Looper.getMainLooper().getThread().getId()) {
            if (handler == null) {
                handler = new Handler(Looper.getMainLooper());
            }

            handler.post(runnable);
        } else {
            runnable.run();
        }

    }

    public static void onNewThread(Runnable runnable) {
        (new Thread(runnable)).start();
    }

    public static void onThreadPool(Runnable runnable) {
        if (runnable != null) {
            if (threadPool == null) {
                Class var1 = UIThreadManager.class;
                synchronized(UIThreadManager.class) {
                    if (threadPool == null) {
                        threadPool = Executors.newFixedThreadPool(5);
                    }
                }
            }

            threadPool.execute(runnable);
        }
    }
}

